package com.share.rule.api;

import com.share.common.core.constant.ServiceNameConstants;
import com.share.common.core.domain.R;
import com.share.rule.api.domain.FeeRule;
import com.share.rule.api.domain.FeeRuleRequestForm;
import com.share.rule.api.domain.FeeRuleResponseVo;
import com.share.rule.api.factory.RemoteFeeRuleFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 远程调用规则接口
 *
 * @author YC
 */
@FeignClient(
        contextId = "remoteFeeRuleService",
        value = ServiceNameConstants.SHARE_RULE,
        fallbackFactory = RemoteFeeRuleFallbackFactory.class
)
public interface RemoteFeeRuleService {

    /**
     * 远程调用 - 根据规则ID集合批量获取费用规则信息
     *
     * @param feeRuleIdList 规则ID集合
     * @return 规则信息集合
     */
    @PostMapping(value = "/feeRule/getFeeRuleList")
    R<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> feeRuleIdList);

    /**
     * 远程调用 - 根据规则ID获取费用规则详细信息
     *
     * @param id 规则ID
     * @return 规则详细信息
     */
    @GetMapping(value = "/feeRule/getFeeRule/{id}")
    R<FeeRule> detailFeeRule(@PathVariable("id") Long id);

    /**
     * 远程调用 - 计算订单费用
     *
     * @param feeRuleRequestForm 规则请求表单
     * @return 封装的规则计算响应
     */
    @PostMapping("/feeRule/calculateOrderFee")
    R<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm feeRuleRequestForm);

}
